package com.xxk.rocket.star.core.annotation.impl;

import com.xxk.rocket.star.annotation.StargateThreadSize;
import com.xxk.rocket.star.core.annotation.AbsProcessAnnotationConsume;
import com.xxk.rocket.star.core.dto.StargateThreadSizeDTO;

import java.lang.reflect.Method;

public class StargateThreadSizeProcessAnnotation
        extends AbsProcessAnnotationConsume<StargateThreadSizeDTO> {

  @Override
  protected void processConsume(StargateThreadSizeDTO stargateThreadSizeDTO, Class aClass, Object o,
                                Method method) throws Throwable {
    StargateThreadSize stargateThreadSize = null;
    if (method == null) {
      stargateThreadSize = (StargateThreadSize) aClass.getAnnotation(StargateThreadSize.class);
    } else {
      stargateThreadSize = method.getAnnotation(StargateThreadSize.class);
    }
    if (stargateThreadSize == null || stargateThreadSize.value() <= 0) {
      return;
    }
    stargateThreadSizeDTO.setThreadSize(stargateThreadSize.value());
  }
}
